// pages/more-news/more-news.js
import util from "../../../../utils/util.js"
Page({

    /**
     * 页面的初始数据
     */
    data: {
        popupShow: true, //弹出层是否[可以]显示,
        search: "",
        skip: 0,
        nomore: false,
        nomoreshow:false,
        onloadtype: 0, //0是初始化，1是筛选，2是搜索
        dataList_area: {
            '不限': [],
            '广州市': ['越秀区', '海珠区', '荔湾区', '天河区', '白云区', '黄埔区', '花都区', '番禺区', '南沙区', '从化区', '增城区'],
            '重庆市': [],
            '长春市': [],
            '成都市': [],
            '长沙市': [],
            '大连市': [],
        },
        filterArray_notice_type: [{
            title: '通知类型',
            buttonList: ['不限', '笔试通知', '面试通知', '名单公示', '其他通知']
        }],
        filterArray_time: [{
            title: '发布时间',
            buttonList: ['不限', '今天', '最近1天', '最近3天', '最近1个月', '最近3个月', '最近半年']
        }],
        filterArray_apply: [{
                title: '报名方式',
                buttonList: ['不限', '网络报名', '线下报名']
            },
            {
                title: '报名时间',
                buttonList: ['不限', '正在报名', '即将报名', '结束报名']
            }
        ],
        filterArray_staffing: [{
            title: '编制',
            buttonList: ['不限', '编制内', '编制外']
        }],
        //用于请求云函数的筛选参数,记录当前页面已经选择了哪个筛选项
        filterOptions: {
            city: '', //市
            district: '', //区
            EnType: -1, //0表示网络报名，1表示线下报名，-1表示不限
            status: -1, //0表示未开始报名，1表示正在报名，2表示报名截至，-1表示不限
            flag: -1, //发布时间0：时间限制为今天；1：时间限制为最近一天；2：时间限制为最近三天；3：时间限制为最近一个月；4：时间限制为最近三个月；5：时间限制为最近半年
            type: -1
        },
        filterOptions2: {
            city: '', //市
            district: '', //区
            type: -1,
            flag: -1 //发布时间0：时间限制为今天；1：时间限制为最近一天；2：时间限制为最近三天；3：时间限制为最近一个月；4：时间限制为最近三个月；5：时间限制为最近半年
        },
        type: 0, //0为招教公告，1为通知公告，2为新闻资讯，3是政策动态
        title: ["招教公告", "通知公示", "新闻资讯", "政策动态"],
        placeholder: "搜索新闻资讯",
        publishList: [],
        infList: [],
        newsList: [],
        policyList: [],
        state: ['即将报名', '正在报名', '结束报名'],
    },
    bindKeyInput(e) {
        this.setData({
            search: e.detail.value
        })
    },
    go_detail(e) {
        let k = e.currentTarget.dataset.index;
        console.log(this.data.publishList[k]._id);
        wx.navigateTo({
            url: '../../publishList_detail/1?_id=' + this.data.publishList[k]._id,
        })
    },
    go_notice_detail(e) {
        let k = e.currentTarget.dataset.index;
        wx.navigateTo({
            url: '../../Notice_detail/Notice_detail?_id=' + this.data.infList[k]._id,
        })
    },
    go_news_detail(e) {
        console.log(e.detail);
        wx.navigateTo({
            url: '../../news_detail/news_detail?_id=' + this.data.newsList[e.detail]._id,
        })
    },
    go_policy_detail(e) {
        console.log(e.detail);
        wx.navigateTo({
            url: '../../policy_detail/policy_detail?_id=' + this.data.policyList[e.detail]._id,
        })
    },
    JumpToSearch() {
        this.setData({
            skip: 0,
            publishList: [],
            newsList: [],
            policyList: [],
            infList: [],
            onloadtype: 2,
            nomore: false,

        })
        let type = 0;
        if (this.data.type == 0) {
            type = 12;
        } else if (this.data.type == 1) {
            type = 16;
        } else if (this.data.type == 2) {
            type = 17;
        } else if (this.data.type == 3) {
            type = 18;
        }
        wx.$cloud.callFunction({
            name: 'getIndexInfo',
            data: {
                sign: type,
                search: this.data.search,
                skip: this.data.skip
            },
            success: res => {
                let ans = res.result.data;
                console.log(ans);
                let k = {};
                let end = [];
                if (this.data.type == 0) {
                    for (let i = 0; i < ans.length; i++) {
                        k.tit = ans[i].title;
                        k.begintime = util.formatTime(new Date(ans[i].StartTime));
                        k.endtime = util.formatTime(new Date(ans[i].EndTime));
                        k.unit = ans[i].apart;
                        k.publishtime = util.formatTime(new Date(ans[i].date));
                        k.state = ans[i].status;
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    if(ans.length==0){
                        this.setData({
                            nomoreshow:true
                        })
                    }
                    else{
                        this.setData({
                            nomoreshow:false
                        })
                    }
                    this.setData({
                        publishList: end
                    })
                } else if (this.data.type == 1) {
                    for (let i = 0; i < ans.length; i++) {
                        k.title = ans[i].title;
                        k.time = util.formatTime(new Date(ans[i].date));
                        k.site = ans[i].apart;
                        if (ans[i].type == 0) {
                            k.type = "笔试通知"
                        } else if (ans[i].type == 1) {
                            k.type = "面试通知"
                        } else if (ans[i].type == 2) {
                            k.type = "名单公示"
                        } else if (ans[i].type == 3) {
                            k.type = "其他通知"
                        }
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    if(ans.length==0){
                        this.setData({
                            nomoreshow:true
                        })
                    }
                    else{
                        this.setData({
                            nomoreshow:false
                        })
                    }
                    this.setData({
                        infList: end,
                    })
                } else if (this.data.type == 2) {
                    for (let i = 0; i < ans.length; i++) {
                        k.tit = ans[i].title;
                        k.time = util.formatTime(new Date(ans[i].date));
                        k.imageurl = ans[i].picture;
                        k.unit = ans[i].apart;
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    if(ans.length==0){
                        this.setData({
                            nomoreshow:true
                        })
                    }
                    this.setData({
                        newsList: end,
                    })
                } else if (this.data.type == 3) {
                    for (let i = 0; i < ans.length; i++) {
                        k.tit = ans[i].title;
                        k.time = util.formatTime(new Date(ans[i].date));
                        k.imageurl = ans[i].picture;
                        k.unit = ans[i].apart;
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    if(ans.length==0){
                        this.setData({
                            nomoreshow:true
                        })
                    }
                    else{
                        this.setData({
                            nomoreshow:false
                        })
                    }
                    this.setData({
                        policyList: end,
                    })
                }
            }
        })

    },
    commonConfirmFilter() { //通用的筛选确定操作
        this.setData({
            publishList: [],
            skip: 0,
            onloadtype: 1,
            nomore: false
        })
        this.setData({
            popupShow: false
        })
        this.setData({
            popupShow: true
        })
        console.log("data:-------------",this.data.filterOptions)
        wx.$cloud.callFunction({
            name: 'getIndexInfo',
            data: {
                sign: 9,
                ...this.data.filterOptions,
                skip: this.data.skip
            }
        }).then(res => {
            let ans = res.result.data;
            console.log(ans);
            let k = {};
            let end = [];
            for (let i = 0; i < ans.length; i++) {
                k.tit = ans[i].title;
                k.begintime = util.formatTime(new Date(ans[i].StartTime));
                k.endtime = util.formatTime(new Date(ans[i].EndTime));
                k.unit = ans[i].apart;
                k.publishtime = util.formatTime(new Date(ans[i].date));
                k.state = ans[i].status;
                k._id = ans[i]._id;
                end.push(k);
                k = {};
            }
            if(ans.length==0){
                this.setData({
                    nomoreshow:true
                })
            }
            else{
                this.setData({
                    nomoreshow:false
                })
            }
            this.setData({
                publishList: this.data.publishList.concat(end)

            })
            console.log(ans);
        })
    },
    confirmFilter1(e) {
        let ans = e.detail.selectedValue;
        const filterOptions = {...this.data.filterOptions }
        if (ans == '不限') {
            filterOptions.flag = -1;
        } else if (ans == '今天') {
            filterOptions.flag = 0;
        } else if (ans == '最近1天') {
            filterOptions.flag = 1;
        } else if (ans == '最近3天') {
            filterOptions.flag = 2;
        } else if (ans == '最近1个月') {
            filterOptions.flag = 3;
        } else if (ans == '最近3个月') {
            filterOptions.flag = 4;
        } else if (ans == '最近半年') {
            filterOptions.flag = 5;
        }

        this.setData({
            filterOptions: filterOptions
        })
        console.log(this.data.filterOptions);
        this.commonConfirmFilter();

    },
    confirmFilter2(e) {
        const filterOptions = {...this.data.filterOptions }
        if (e.detail.firstVal != '不限') {
            filterOptions.city = e.detail.firstVal
        } else {
            filterOptions.city = ''
        }
        if (e.detail.secondVal != '不限') {
            filterOptions.district = e.detail.secondVal
        } else {
            filterOptions.district = ''
        }
        this.setData({
            filterOptions: filterOptions
        })

        console.log(this.data.filterOptions)
        this.commonConfirmFilter();

    },
    confirmFilter3(e) {
        console.log('筛选确定了3')

        const filterOptions = {...this.data.filterOptions }
        if (e.detail.selectedValue[0] == '不限') {
            filterOptions.EnType = -1
        } else if (e.detail.selectedValue[0] == '网络报名') {
            filterOptions.EnType = 0
        } else if (e.detail.selectedValue[0] == '线下报名') {
            filterOptions.EnType = 1
        }
        if (e.detail.selectedValue[1] == '不限') {
            filterOptions.status = -1
        } else if (e.detail.selectedValue[1] == '即将报名') {
            filterOptions.status = 0
        } else if (e.detail.selectedValue[1] == '正在报名') {
            filterOptions.status = 1
        } else if (e.detail.selectedValue[1] == '结束报名') {
            filterOptions.status = 2
        }
        this.setData({
            filterOptions: filterOptions
        })
        this.commonConfirmFilter()
    },
    confirmFilter4(e) {
        this.setData({
            publishList: []
        })
        console.log('筛选确定了4')
        let ans = e.detail.selectedValue;
        const filterOptions = {...this.data.filterOptions }
        if (ans == '不限') {
            filterOptions.type = -1;
        } else if (ans == '编制内') {
            filterOptions.type = 0;
        } else if (ans == '编制外') {
            filterOptions.type = 1;
        }
        this.setData({
            filterOptions: filterOptions
        })
        this.commonConfirmFilter()
    },
    commonConfirmFilter2() { //通用的筛选确定操作
        this.setData({
            popupShow: false,
            infList: [],
            skip: 0,
            onloadtype: 1,
            nomore: false
        })
        this.setData({
            popupShow: false
        })
        this.setData({
            popupShow: true
        })
        wx.$cloud.callFunction({
            name: 'getIndexInfo',
            data: {
                sign: 4,
                ...this.data.filterOptions2,
                skip: this.data.skip
            }
        }).then(res => {
            let ans = res.result.data;
            console.log(ans);
            let k = {};
            let end = [];
            for (let i = 0; i < ans.length; i++) {
                k.title = ans[i].title;
                k.time = util.formatTime(new Date(ans[i].date));
                k.site = ans[i].apart;
                if (ans[i].type == 0) {
                    k.type = "笔试通知"
                } else if (ans[i].type == 1) {
                    k.type = "面试通知"
                } else if (ans[i].type == 2) {
                    k.type = "名单公示"
                } else if (ans[i].type == 3) {
                    k.type = "其他通知"
                }
                k._id = ans[i]._id;
                end.push(k);
                k = {};
            }
            this.setData({
                infList: this.data.infList.concat(end)
            })
        })
    },
    confirmFilter5(e) {
        const filterOptions = {...this.data.filterOptions2 }
        if (e.detail.firstVal != '不限') {
            filterOptions.city = e.detail.firstVal
        } else {
            filterOptions.city = ''
        }
        if (e.detail.secondVal != '不限') {
            filterOptions.district = e.detail.secondVal
        } else {
            filterOptions.district = ''
        }
        this.setData({
            filterOptions2: filterOptions
        })

        this.commonConfirmFilter2();

    },
    confirmFilter6(e) {
        console.log(e)
        const filterOptions = {...this.data.filterOptions2 }
        let ans = e.detail.selectedValue;
        console.log(ans)
        if (ans == '不限') {
            filterOptions.type = -1;
        } else if (ans == '笔试通知') {
            filterOptions.type = 0;
        } else if (ans == '面试通知') {
            filterOptions.type = 1;
        } else if (ans == '名单公示') {
            filterOptions.type = 2;
        } else if (ans == '其他通知') {
            filterOptions.type = 3;
        }
        this.setData({
            filterOptions2: filterOptions
        })
        this.commonConfirmFilter2();

    },
    confirmFilter7(e) {
        console.log(e)
        const filterOptions = {...this.data.filterOptions2 }
        let ans = e.detail.selectedValue;
        console.log(ans)
        if (ans == '不限') {
            filterOptions.flag = -1;
        } else if (ans == '今天') {
            filterOptions.flag = 0;
        } else if (ans == '最近1天') {
            filterOptions.flag = 1;
        } else if (ans == '最近3天') {
            filterOptions.flag = 2;
        } else if (ans == '最近1个月') {
            filterOptions.flag = 3;
        } else if (ans == '最近3个月') {
            filterOptions.flag = 4;
        } else if (ans == '最近半年') {
            filterOptions.flag = 5;
        }
        this.setData({
            filterOptions2: filterOptions
        })
        this.commonConfirmFilter2();

    },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: async function(option) {
        // const eventChannel = this.getOpenerEventChannel()
        // 监听acceptDataFromOpenerPage事件，获取上一页面通过eventChannel传送到当前页面的数据

        //设置好当前页面的type
        // eventChannel.on('acceptDataFromOpenerPage', (data) => {
        //     // console.log(data)
        //     const type = data.type;
        //     const placeholder = "搜索" + this.data.title[type];
        //     this.setData({
        //         type: type,
        //         placeholder: placeholder
        //     })
        // })
        wx.showLoading({
            title: '请稍候...',
            duration:2000
          })
        const type = option.type;
        let placeholder = "";
        if (type == 0) {
            placeholder = "搜索教职/学校/地区,关键字间请用空格隔开";
        } else if (type == 1) {
            placeholder = "搜索教职/学校/地区,关键字间请用空格隔开"
        } else if (type == 2) {
            placeholder = "搜索新闻资讯"
        } else if (type == 3) {
            placeholder = "搜索政策动态"
        }
        this.setData({
                type: type,
                placeholder: placeholder
            })
            //根据页面type动态设置页面导航栏标题和搜索框占位符
        const pageTile = String(this.data.title[this.data.type]);
        wx.setNavigationBarTitle({
            title: pageTile, //页面标题
            success: () => {}, //接口调用成功的回调函数
            fail: () => {}, //接口调用失败的回调函数
            complete: () => {} //接口调用结束的回调函数（调用成功、失败都会执行）
        })
        if(type==0||type==1){
            /*
            await wx.cloud.callFunction({
                name: 'getCityInf',
                data: {
                    action: "getCities",
                    limit: 100
                },
            }).then(async(res) => {
                console.log(res)
                let ans = res.result.data;
                let k = {};
                k["不限"] = new Array(0);
                for (let i = 0; i < ans.length; i++) {
                    if (ans[i].city != null) {
                        let s = ans[i].city + "市";
                        k[s] = new Array(0);
                        await wx.cloud.callFunction({
                            name: 'getCityInf',
                            data: {
                                action: "getAreas",
                                cityName: ans[i].city
                            }
                        }).then(res => {
                            console.log(s, res)
                            k[s] = res.result.data[0].area
                        })

                    } else {
                        break;
                    }
                }
                console.log(k)
                this.setData({
                    dataList_area: k,
                    ready: true
                })
                
                console.log(this.data.dataList_area);
            })*/
            var temp=await wx.$cloud.callFunction({
                name: 'getCityInf',
                data: {
                    action: "getAllInfo",
                }
               })
               temp=temp.result
               var dataList_area={}
               dataList_area["不限"] = []
               for(let i=0;i<temp.length;i++){
                dataList_area[temp[i].city+'市']=temp[i].area
               }
               this.setData({
                dataList_area: dataList_area,
                ready: true
               })
        }
       
        this.getData(type)
            //根据页面type请求接口新闻列表...
            //...
            //...
    },
    getData(type) {
        if (type == 0) {
          
            wx.$cloud.callFunction({
                name: 'getIndexInfo',
                data: {
                    sign: 9,
                    flag: -1,
                    skip: this.data.skip
                },
                success: res => {
                    let ans = res.result.data;
                    console.log(ans);
                    if (ans.length == 0) {
                        this.setData({
                            nomore: true
                        })
                    }
                    let k = {};
                    let end = [];
                    for (let i = 0; i < ans.length; i++) {
                        k.tit = ans[i].title;
                        k.begintime = util.formatTime(new Date(ans[i].StartTime));
                        k.endtime = util.formatTime(new Date(ans[i].EndTime));
                        k.unit = ans[i].apart;
                        k.publishtime = util.formatTime(new Date(ans[i].date));
                        k.state = ans[i].status;
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                
                    this.setData({
                        publishList: this.data.publishList.concat(end)
                    })
                }
            })

        } else if (type == 1) {
            wx.$cloud.callFunction({
                name: 'getIndexInfo',
                data: {
                    sign: 4,
                    skip: this.data.skip
                },
                success: res => {
                    let ans = res.result.data;
                    console.log(ans);
                    if (ans.length == 0) {
                        this.setData({
                            nomore: true
                        })
                    }
                    let k = {};
                    let end = [];
                    for (let i = 0; i < ans.length; i++) {
                        k.title = ans[i].title;
                        k.time = util.formatTime(new Date(ans[i].date));
                        k.site = ans[i].apart;
                        if (ans[i].type == 0) {
                            k.type = "笔试通知"
                        } else if (ans[i].type == 1) {
                            k.type = "面试通知"
                        } else if (ans[i].type == 2) {
                            k.type = "名单公示"
                        } else if (ans[i].type == 3) {
                            k.type = "其他通知"
                        }
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    this.setData({
                        infList: this.data.infList.concat(end),
                    })
                }
            })
            // await wx.cloud.callFunction({
            //     name: 'getCityInf',
            //     data: {
            //         action: "getCities",
            //         limit: 100
            //     },
            // }).then(async(res) => {
            //     console.log(res)
            //     let ans = res.result.data;
            //     let k = {};
            //     k["不限"] = new Array(0);
            //     for (let i = 0; i < ans.length; i++) {
            //         if (ans[i].city != null) {
            //             let s = ans[i].city + "市";
            //             k[s] = new Array(0);
            //             await wx.cloud.callFunction({
            //                 name: 'getCityInf',
            //                 data: {
            //                     action: "getAreas",
            //                     cityName: ans[i].city
            //                 }
            //             }).then(res => {
            //                 console.log(s, res)
            //                 k[s] = res.result.data[0].area
            //             })

            //         } else {
            //             break;
            //         }
            //     }
            //     console.log(k)
            //     this.setData({
            //         dataList_area: k,
            //         ready: true
            //     })
            //     console.log(this.data.dataList_area);
            // })
           

        } else if (type == 2) {
            wx.$cloud.callFunction({
                name: 'getIndexInfo',
                data: {
                    sign: 10,
                    skip: this.data.skip
                },
                success: res => {
                    let ans = res.result.data;
                    console.log(ans)
                    if (ans.length == 0) {
                        this.setData({
                            nomore: true
                        })
                    }
                    let k = {};
                    let end = [];
                    for (let i = 0; i < ans.length; i++) {
                        k.tit = ans[i].title;
                        k.time = util.formatTime(new Date(ans[i].date));
                        k.imageurl = ans[i].picture;
                        k.unit = ans[i].apart;
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    this.setData({
                        newsList: this.data.newsList.concat(end),
                    })
                }
            })

        } else if (type == 3) {
            wx.$cloud.callFunction({
                name: 'getIndexInfo',
                data: {
                    sign: 11,
                    skip: this.data.skip
                },
                success: res => {
                    let ans = res.result.data;
                    if (ans.length == 0) {
                        this.setData({
                            nomore: true
                        })
                    }
                    let k = {};
                    let end = [];
                    for (let i = 0; i < ans.length; i++) {
                        k.tit = ans[i].title;
                        k.time = util.formatTime(new Date(ans[i].date));
                        k.imageurl = ans[i].picture;
                        k.unit = ans[i].apart;
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    this.setData({
                        policyList: this.data.policyList.concat(end),
                    })
                }
            })
        }

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

        //根据页面type动态设置页面导航栏标题和搜索框占位符
        const pageTile = String(this.data.title[this.data.type]);
        wx.setNavigationBarTitle({
            title: pageTile, //页面标题
            success: () => {}, //接口调用成功的回调函数
            fail: () => {}, //接口调用失败的回调函数
            complete: () => {} //接口调用结束的回调函数（调用成功、失败都会执行）
        })

        //根据页面type请求接口新闻列表...
        //...
        //...
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {
        this.setData({
            skip: this.data.skip + 1
        })
        if (this.data.onloadtype == 0) {
            this.getData(this.data.type)
        }
        if (this.data.onloadtype == 1) {
            if (this.data.type == 0) {
                wx$cloud.callFunction({
                    name: 'getIndexInfo',
                    data: {
                        sign: 9,
                        ...this.data.filterOptions,
                        skip: this.data.skip
                    }
                }).then(res => {
                    let ans = res.result.data;
                    console.log(ans);
                    if (ans.length == 0) {
                        this.setData({
                            nomore: true
                        })
                    }
                    let k = {};
                    let end = [];
                    for (let i = 0; i < ans.length; i++) {
                        k.tit = ans[i].title;
                        k.begintime = util.formatTime(new Date(ans[i].StartTime));
                        k.endtime = util.formatTime(new Date(ans[i].EndTime));
                        k.unit = ans[i].apart;
                        k.publishtime = util.formatTime(new Date(ans[i].date));
                        k.state = ans[i].status;
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    this.setData({
                        publishList: this.data.publishList.concat(end)

                    })
                    console.log(ans);
                })
            }
            if (this.data.type == 1) {
                wx.$cloud.callFunction({
                    name: 'getIndexInfo',
                    data: {
                        sign: 4,
                        ...this.data.filterOptions2,
                        skip: this.data.skip
                    }
                }).then(res => {
                    let ans = res.result.data;
                    console.log(ans);
                    if (ans.length == 0) {
                        this.setData({
                            nomore: true
                        })
                    }
                    let k = {};
                    let end = [];
                    for (let i = 0; i < ans.length; i++) {
                        k.title = ans[i].title;
                        k.time = util.formatTime(new Date(ans[i].date));
                        k.site = ans[i].apart;
                        if (ans[i].type == 0) {
                            k.type = "笔试通知"
                        } else if (ans[i].type == 1) {
                            k.type = "面试通知"
                        } else if (ans[i].type == 2) {
                            k.type = "名单公示"
                        } else if (ans[i].type == 3) {
                            k.type = "其他通知"
                        }
                        k._id = ans[i]._id;
                        end.push(k);
                        k = {};
                    }
                    this.setData({
                        infList: this.data.infList.concat(end)
                    })
                })
            }
        }
        if (this.data.onloadtype == 2) {
            let type = 0;
            if (this.data.type == 0) {
                type = 12;
            } else if (this.data.type == 1) {
                type = 16;
            } else if (this.data.type == 2) {
                type = 17;
            } else if (this.data.type == 3) {
                type = 18;
            }
            wx.$cloud.callFunction({
                name: 'getIndexInfo',
                data: {
                    sign: type,
                    search: this.data.search,
                    skip: this.data.skip
                },
                success: res => {
                    let ans = res.result.data;
                    console.log(ans);
                    if (ans.length == 0) {
                        this.setData({
                            nomore: true
                        })
                    }
                    let k = {};
                    let end = [];
                    if (this.data.type == 0) {
                        for (let i = 0; i < ans.length; i++) {
                            k.tit = ans[i].title;
                            k.begintime = util.formatTime(new Date(ans[i].StartTime));
                            k.endtime = util.formatTime(new Date(ans[i].EndTime));
                            k.unit = ans[i].apart;
                            k.publishtime = util.formatTime(new Date(ans[i].date));
                            k.state = ans[i].status;
                            k._id = ans[i]._id;
                            end.push(k);
                            k = {};
                        }
                        this.setData({
                            publishList: this.data.publishList.concat(end)
                        })
                    } else if (this.data.type == 1) {
                        for (let i = 0; i < ans.length; i++) {
                            k.title = ans[i].title;
                            k.time = util.formatTime(new Date(ans[i].date));
                            k.site = ans[i].apart;
                            if (ans[i].type == 0) {
                                k.type = "笔试通知"
                            } else if (ans[i].type == 1) {
                                k.type = "面试通知"
                            } else if (ans[i].type == 2) {
                                k.type = "名单公示"
                            } else if (ans[i].type == 3) {
                                k.type = "其他通知"
                            }
                            k._id = ans[i]._id;
                            end.push(k);
                            k = {};
                        }
                        this.setData({
                            infList: this.data.infList.concat(end),
                        })
                    } else if (this.data.type == 2) {
                        for (let i = 0; i < ans.length; i++) {
                            k.tit = ans[i].title;
                            k.time = util.formatTime(new Date(ans[i].date));
                            k.imageurl = ans[i].picture;
                            k.unit = ans[i].apart;
                            k._id = ans[i]._id;
                            end.push(k);
                            k = {};
                        }
                        this.setData({
                            newsList: this.data.newsList.concat(end),
                        })
                    } else if (this.data.type == 3) {
                        for (let i = 0; i < ans.length; i++) {
                            k.tit = ans[i].title;
                            k.time = util.formatTime(new Date(ans[i].date));
                            k.imageurl = ans[i].picture;
                            k.unit = ans[i].apart;
                            k._id = ans[i]._id;
                            end.push(k);
                            k = {};
                        }
                        this.setData({
                            policyList: this.data.policyList.concat(end),
                        })

                    }
                }
            })
        }


    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },
    //筛选确定之后触发
    confirmFilter(e) {
        console.log('筛选确定了')
        console.log('e.detail:', e.detail)
            //相当于刷新一下，起到了收回筛选栏的效果
        this.setData({
            popupShow: false
        })
        this.setData({
            popupShow: true
        })
    },
})